<?php
/**
 * UserController.php
 *
 * @category    Madoqua
 * @package     Module
 * @subpackage  Install
 */

/** base class */
require_once 'Madoqua/Controller/Action/Abstract.php';

/**
 * Install_UserController
 *
 * @category    Madoqua
 * @package     Module
 * @subpackage  Install
 */
class Install_UserController extends Madoqua_Controller_Action_Abstract
{
    /**
     * create an admin user
     */
    public function indexAction()
    {
        $form = $this->_formLoader->get();

        if ($form->isPrg() && $form->isValidPrg()) {
            //woo!
            
            $this->_modelLoader->load('Front_User');
            $userModel = new Front_User();
            //user model
            
            $userModel->insert($form->getValues());
            //insert new user
            
            $options = array(
                'module' => 'install',
                'action' => 'finish'
            );
            Madoqua_Redirector::redirectAndExit($options, 'default', true);              
        }
        
        $this->view->form = $form;
    }
}